package jdklearning.stream;


import java.util.Arrays;
import java.util.List;

import static java.util.stream.Collectors.toList;

/**
 * @author shenenlu 2021年03月23日 上午11:35:20
 */
public class StreamLearning {


    public static void flatMap(){
        String[] strings = {"Hello", "World"};
        List<String> collect = Arrays.stream(strings)
                .map(r -> r.split(""))
                .flatMap(Arrays::stream)
//                .distinct()
                .collect(toList());

        collect.forEach(System.out::println);


        List<String> collect1 = Arrays.stream(strings).collect(toList());
        collect1.forEach(System.out::println);
    }

    public static void main(String[] args) {
        flatMap();
    }

}
